/*
    BloatedHammer (API Hammering) in Rust
    By @5mukx
    Original Credit Goes to rad9800: https://github.com/rad9800/BloatedHammer/tree/master

    References i looked while i code: 
        * https://unit42.paloaltonetworks.com/api-hammering-malware-families/
        * https://github.com/rad9800/BloatedHammer/tree/master

*/

macro_rules! bloat {
    ($size:expr, $fn:expr) => {
        (0..$size).for_each(|i| $fn(i));
    };
}

fn main() {
    bloat!(512, |val: usize| {
        let mod_val = val % 4;
        match mod_val {
            0 => {
                bloat!(256, |_| {
                    println!("Case 0 recursive.");
                });
            },
            1 => {
                bloat!(32, |_| {
                    println!("Case 1 recursive.");
                    bloat!(32, |_| {
                        println!("Case 1 double recursive.");
                        bloat!(32, |_| {
                            println!("Case 1 triple recursive.");
                        });
                    });
                });
            },
            2 => {
                bloat!(256, |_| {
                    println!("Case 2 recursive.");
                });
            },
            3 => {
                bloat!(256, |_| {
                    println!("Case 3 recursive.");
                });
            },
            _ => {}
        }
    });
}
